import React, { Component } from 'react'
import { HashRouter as Hash, BrowserRouter as History, Route, Switch, Redirect } from 'react-router-dom'
import NotFound from './errorpage/404'
import BadGateaway from './errorpage/503'

import Lazyload from '../utils/lazyload'


export class MainRouter extends Component {
    render() {
        return (
            <Hash
                basename=""
            >
                <Route component={MainLayout} />
            </Hash>
        )
    }
}


//页面的主视图

export class MainLayout extends Component {
    render() {
        return (
            <div className="layout">
                <Switch>
                    <Route path='/' exact render={() => <Redirect to='/login' />} />
                    <Route path='/login' component={Lazyload(() => import('./login'))} />
                    <Route path='/main' component={Lazyload(() => import('./main'))} />
                    <Route path='/503' component={Lazyload(() => import('./errorpage/503'))} />
                    <Route path='/404' component={Lazyload(() => import('./errorpage/404'))} />
                    <Route render={() => <Redirect to='/404' />} />
                </Switch>
            </div>
        )
    }
}

